package com.mall.cloud.service;

import com.mall.cloud.bean.User;
import com.mall.cloud.common.CommonResult;
import com.mall.cloud.service.fallback.UserFallbackService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

//value:对eureka-client服务的接口调用客户端；fallback：设置服务降级处理类为UserFallbackService
@FeignClient(value = "eureka-client", fallback = UserFallbackService.class)
public interface UserService {

    @PostMapping("/user/create")
    CommonResult<User> create(@RequestBody User user);

    @GetMapping("/user/{id}")
    CommonResult<User> getUser(@PathVariable Long id);

    @GetMapping("/user/getByUsername")
    CommonResult<User> getByUsername(@RequestParam String username);

    @PutMapping("/user/update")
    CommonResult<User> update(@RequestBody User user);

    @DeleteMapping("/user/delete/{id}")
    CommonResult<User> delete(@PathVariable Long id);
}
